<template>
  <a-modal
    :title="title"
    :width="width"
    :visible="visible"
    :confirmLoading="confirmLoading"
    @cancel="handleCancel"
    v-drag
  >
    <template slot="footer">
      <a-button @click="handleCancel">{{$t('关闭')}}</a-button>
    </template>
    <a-row>
      <a-col :span="6"><span>{{$t('活动名称')}}：</span><span style="font-weight:600;color:#000">{{model.name}}</span></a-col>
      <a-col :span="6"><span>{{$t('有效抽奖次数')}}：</span><span style="font-weight:600;color:#000">{{model.num}}</span></a-col>
      <a-col :span="6"><span>{{$t('已抽奖次数')}}：</span><span style="font-weight:600;color:#000">{{model.use}}</span></a-col>
      <a-col :span="6"><span>{{$t('中奖次数')}}：</span><span style="font-weight:600;color:#F00">{{model.win}}</span></a-col>
    </a-row>
    <div style="margin-top:10px">
      <a-table
        ref="table"
        size="middle"
        :scroll="{ x: true }"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="model.useList"
        :pagination="false"
        :loading="loading"
        class="j-table-force-nowrap"
      >
      </a-table>
    </div>
  </a-modal>
</template>

<script>
import '@/assets/less/TableExpand.less'
import { getAction, downFile } from '@/api/manage'

export default {
  name: 'DrawSumModal',
  mixins: [],
  components: {},
  data() {
    return {
      // 表头
      columns: [
        {
          title: this.$t('奖品名称'),
          align: 'center',
          dataIndex: 'goodsId_dictText',
        },
        {
          title: this.$t('中奖次数'),
          align: 'center',
          dataIndex: 'amount',
          customCell: (text, record) => {
            return {
              style: {
                textAlign: 'right',
              },
            }
          },
        },
      ],
      dataSource:[],
      loading: false,
      title: this.$t('抽奖汇总'),
      width: 800,
      visible: false,
      confirmLoading: false,
      model: {},
    }
  },
  computed: {
    importExcelUrl: function () {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
    },
  },
  methods: {
    initDictConfig() {
    },
    show(record) {
      this.model=Object.assign({},record,{useList:[],use:0,win:0,num:0})
      this.visible = true
      getAction('/activity/bisMemberDraw/numTotal',{activityId:this.model.id}).then(res=>{
        if(res.success){
          this.$set(this,'model',Object.assign({},this.model,res.result))
        }
      })
    },
    handleCancel() {
      this.visible = false
    },
  },
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>